
import pathlib
class reportTotext :
    def __init__(self,filepath,log):
        self.info="********************记录*******************\n"
        self.error="*****************异常记录*****************\n"
        self.filepath=pathlib.Path(filepath)
        self.log=log

    def i(self,str):
        self.log.info(str)
        self.info=self.info+str+"\n"
    def e(self,str):
        self.log.error(str)
        self.error=self.error+str+"\n"
    def save(self):
        self.log.debug(self.filepath.stem)
        self.log.debug(self.filepath.parent)
        reportPath=pathlib.Path(self.filepath.parent)/pathlib.Path(self.filepath.stem+"检查报告.txt")
        self.log.debug(reportPath)
        with open(reportPath, 'w') as f:
            f.write(self.error)
            f.write(self.info)